//
//  Layout.m
//  HYHOME
//
//  Created by cjy on 16/3/3.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "Layout.h"
#import "ModelS.h"
#import "UIImageView+WebCache.h"
#import "DKNightVersion.h"
@implementation Layout

- (void)dealloc{

    [_label_name release];
    [_imageV release];
    [super dealloc];


}

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
//        self.dk_backgroundColorPicker = DKColorWithRGB(0xffffff, 0x343434);
        // 创建子控件
        
        
        
        
        self.imageV = [[UIImageView alloc]init];
        [self.contentView addSubview:self.imageV];
        
        self.label_name = [[UILabel alloc]init];
        [self.imageV addSubview:self.label_name];
        self.label_name.textAlignment = NSTextAlignmentCenter;
        
        [self.imageV release];
        [self.label_name release];
        
        
    }
    
    return self;
    
}



- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    self.imageV.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.width);
    
    self.label_name.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.width);
    self.label_name.textAlignment = NSTextAlignmentCenter;
    self.label_name.dk_textColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor lightGrayColor]);
    
    self.label_name.backgroundColor = [UIColor blackColor];
    self.label_name.alpha = 0.6;
    self.label_name.textColor = [UIColor whiteColor];
    
    
    
    
}


-(UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    return layoutAttributes;
}



- (void)layoutSubviews{
    
    
    [super layoutSubviews];
    
    
    
}

-(void)passModel:(ModelS *)model{
    
    
   [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.url] placeholderImage:[UIImage imageNamed:@"jz"]];
    
    self.label_name.text = model.label_name;
}

@end
